﻿using PerfAssist.Common.Scripts;
using UnityEditor;
using UnityEngine;
using UnityEngine.Assertions;

namespace PerfAssist.Common.Editor.TestCommands
{
    public class TestPACommon : EditorWindow
    {
        [MenuItem(PAEditorConst.DemoTestPath + "/Test UniqueString")]
        private static void TestUniqueString()
        {
            var i = 15;
            var s = "foo" + i;
            var s2 = UniqueString.Intern(s);
            var s3 = UniqueString.Intern(s, false);
            Debug.Log(ReferenceEquals(s, s2));
            Debug.Log(ReferenceEquals(s, s3));
            UniqueString.Clear();
        }

        [MenuItem(PAEditorConst.DemoTestPath + "/Test ChartDataSet")]
        private static void TestPAChartDataSet()
        {
            var ds = new PAChartDataSet(100);
            for (var i = 0; i < 100; i++) ds.Append(new PAChartPlotPoint(i, Random.value * 100.0f));

            Assert.IsTrue(ds.Count == 100);

            ds.ShrinkTo(60);

            Assert.IsTrue(ds.Count == 60);
        }
    }
}